package com.example.bitintershipbbs.mapper;

import com.example.bitintershipbbs.model.Command;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import javax.annotation.ManagedBean;
import java.util.List;

@Mapper
public interface CommandMapper {
    @Insert("insert into command(post_id,creator_id,description,gmt_create,gmt_modified) values (#{post_id},#{creator_id},#{description},#{gmt_create},#{gmt_modified})")
    void createCommand(Command command);

    @Select("select * from command where post_id = #{post_id}")
    List<Command> findByPostId(@Param("post_id") Integer post_id);

    @Select("select * from command where creator_id = #{id} order by gmt_modified limit 1")
    Command getLatest(@Param("id") Integer id);
}
